/*
  move to uncheked list
*/

/*
  move to uncheked list
*/
function moveItemToList(listToDoModelUnChecked, toDoListUnCheckedItems,  elementMoved)
{
    console.log("index item = " +elementMoved.indexItem)
    var findPosition = false;
    listToDoModelChecked.setProperty(index, "parentList","toDoListUnCheckedItems" )
    if(toDoListUnCheckedItems.count >1 )
    {
        var contor =0
        for(contor=0; contor<toDoListUnCheckedItems.count-1; contor++)
        {
            if(listToDoModelUnChecked.get(contor).indexItem < elementMoved.indexItem
               && listToDoModelUnChecked.get(contor+1).indexItem >  elementMoved.indexItem
               )
             {
                //insert on contor+1 position
                 listToDoModelUnChecked.insert(contor+1,elementMoved)
                 findPosition = true
                 break;
            }
            // is first item
            if(contor == 0 && listToDoModelUnChecked.get(contor).indexItem >  elementMoved.indexItem)
            {
                listToDoModelUnChecked.insert(contor,elementMoved)
                findPosition = true
                break;
            }
        }

        //if is last item
        if(listToDoModelUnChecked.get(toDoListUnCheckedItems.count-1).indexItem <  elementMoved.indexItem)
        {
            listToDoModelUnChecked.append(elementMoved)
            findPosition = true
        }

    }
    else
    {
        if(toDoListUnCheckedItems.count == 1 )
        {
            findPosition =  true
            if(listToDoModelUnChecked.get(0).indexItem >  elementMoved.indexItem)
                listToDoModelUnChecked.insert(0,elementMoved)
            else
                listToDoModelUnChecked.append(elementMoved)
        }
    }

   if(toDoListUnCheckedItems.count == 0|| findPosition== false )
        listToDoModelUnChecked.append(elementMoved)

}

//old form
/*
function moveItemToList(elementMoved)
{
    console.log("index item = " +elementMoved.indexItem)
    var findPosition = false;
    listToDoModelChecked.setProperty(index, "parentList","toDoListUnCheckedItems" )
    if(toDoListUnCheckedItems.count >1 )
    {
        var contor =0
        for(contor=0; contor<toDoListUnCheckedItems.count-1; contor++)
        {
            if(listToDoModelUnChecked.get(contor).indexItem < elementMoved.indexItem
               && listToDoModelUnChecked.get(contor+1).indexItem >  elementMoved.indexItem
               )
             {
                //insert on contor+1 position
                 listToDoModelUnChecked.insert(contor+1,elementMoved)
                 findPosition = true
                 break;
            }
            // is first item
            if(contor == 0 && listToDoModelUnChecked.get(contor).indexItem >  elementMoved.indexItem)
            {
                listToDoModelUnChecked.insert(contor,elementMoved)
                findPosition = true
                break;
            }
        }

        //if is last item
        if(listToDoModelUnChecked.get(toDoListUnCheckedItems.count-1).indexItem <  elementMoved.indexItem)
        {
            listToDoModelUnChecked.append(elementMoved)
            findPosition = true
        }

    }
    else
    {
        if(toDoListUnCheckedItems.count == 1 )
        {
            findPosition =  true
            if(listToDoModelUnChecked.get(0).indexItem >  elementMoved.indexItem)
                listToDoModelUnChecked.insert(0,elementMoved)
            else
                listToDoModelUnChecked.append(elementMoved)
        }
    }

   if(toDoListUnCheckedItems.count == 0|| findPosition== false )
        listToDoModelUnChecked.append(elementMoved)

}



*/
